import React, { useState } from 'react'
import { useHistory } from 'react-router-dom'
import { putAccCarriageAddCarriage } from '../../../../financialApi'
import { Button, Form, Input, InputNumber, message } from 'antd'

const { TextArea } = Input;

/**
 * @description: 财务-运输费用申请
 * @author: xiaoxujs
 * @upDate: xiaoxujs（2021-07-07）
 */

const Transportation = () => {
    const history = useHistory()
    const [buttonLoading, setButtonLoading] = useState(false)
    const onFinish = (values) => {
        ; (async () => {
            setButtonLoading(true)
            const { code, msg } = await putAccCarriageAddCarriage(values)
            if (code === '20000') {
                message.success('提交成功')
                setButtonLoading(false)
                history.go('-1')
            } else {
                setButtonLoading(false)
                message.error(msg)
            }
        })()
    };
    return <Form
        labelCol={{ span: 3 }}
        wrapperCol={{ span: 16 }}
        onFinish={onFinish}
    >
        <Form.Item
            label="支付事由"
            name="matter"
            rules={[{ required: true, message: '请输入支付事由!' }]}
        >
            <TextArea />
        </Form.Item>
        <Form.Item
            label="申请金额（元）"
            name="money"
            rules={[{ required: true, message: '请输入申请金额!' }]}
        >
            <InputNumber />
        </Form.Item>

        <Form.Item
            label="运输商"
            name="forwarding"
            rules={[{ required: true, message: '请输入运输商!' }]}
        >
            <Input />
        </Form.Item>
        <Form.Item
            label="联系人员"
            name="linkman"
            rules={[{ required: true, message: '请输入联系人员!' }]}
        >
            <Input />
        </Form.Item>
        <Form.Item
            label="联系电话"
            name="mobile"
            rules={[{ required: true, message: '请输入联系电话!' }]}
        >
            <Input />
        </Form.Item>
        <Form.Item wrapperCol={{ offset: 8, span: 16 }}>
            <Button type="primary" htmlType="submit" loading={buttonLoading}>
                提交申请
            </Button>
        </Form.Item>
    </Form>
}

export default Transportation